﻿<UserControl x:Class="FXSStation.Modules.DataModule.AccountView.AccountView"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
   >
    <StackPanel>
        <Grid>
            <Grid.RowDefinitions>
                <RowDefinition Height="Auto" />
                <RowDefinition Height="Auto" />
            </Grid.RowDefinitions>
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="*" />
                <ColumnDefinition Width="3*" />
            </Grid.ColumnDefinitions>
            <TextBlock Text="Name: " Grid.Column="0" Grid.Row="0"/>
            <TextBlock Text="{Binding Name}" Grid.Column="1" Grid.Row="0"/>
            <TextBlock Text="{Binding Balance.Deposit}" Grid.Column="1" Grid.Row="1" />
            <TextBlock Text="Balance" Grid.Column="0" Grid.Row="1" />
        </Grid>

        <TextBlock Text="Active Orders" FontSize="16" FontWeight="Bold" Margin="0,20,0,0" Foreground="Blue"/>

        <ListView Name="listActiveOrders" ItemsSource="{Binding CurrentSession.ActiveOrders}">
            <ListView.Resources>
                <ContextMenu x:Key="cm">
                    <MenuItem Header="Close order" Click="OnOrderClosed"/>
                </ContextMenu>
                <Style TargetType="{x:Type ListViewItem}">
                    <Setter Property="ContextMenu" Value="{StaticResource cm}"/>
                </Style>
            </ListView.Resources>
            <ListView.View>
                <GridView ColumnHeaderContainerStyle="{DynamicResource ColumnHeaderContainerStyleBase}" ColumnHeaderTemplate="{DynamicResource ColumnHeaderTemplate}">
                    <GridViewColumn Header="Finished" >
                        <GridViewColumn.CellTemplate>
                            <DataTemplate>
                                <Border BorderBrush="Black" Name="btn" BorderThickness="2" CornerRadius="4">
                                    <Button Content="Close Position" Name="btnCloseOrder" Click="OnOrderClosed"/>
                                </Border>
                                <DataTemplate.Triggers>
                                    <DataTrigger Binding="{Binding IsClosed}" Value="True">
                                        <Setter Property="IsEnabled" Value="False"/>
                                    </DataTrigger>
                                </DataTemplate.Triggers>
                            </DataTemplate>
                        </GridViewColumn.CellTemplate>
                    </GridViewColumn>
                    <GridViewColumn Header="Type">
                        <GridViewColumn.CellTemplate>
                            <DataTemplate>
                                <Border>
                                    <DockPanel>
                                        <Ellipse Width="25" Height="15" Name="icon" DockPanel.Dock="Left"  />
                                        <TextBlock Text="{Binding Type}" Name="content" VerticalAlignment="Center" Margin="5,0,0,0"/>
                                    </DockPanel>
                                </Border>
                                <DataTemplate.Triggers>
                                    <Trigger Property="Text" SourceName="content" Value="BuyOrder">
                                        <Setter TargetName="icon" Property="Fill" Value="Blue"/>
                                    </Trigger>
                                    <Trigger Property="Text" SourceName="content" Value="SellOrder">
                                        <Setter TargetName="icon" Property="Fill" Value="Red"/>
                                    </Trigger>
                                </DataTemplate.Triggers>
                            </DataTemplate>
                        </GridViewColumn.CellTemplate>
                    </GridViewColumn>
                    <GridViewColumn Header="Date" DisplayMemberBinding="{Binding Path=TimeStamp}"/>
                    <GridViewColumn Header="Currency Symbol" DisplayMemberBinding="{Binding Path=CurrencySymbol}"/>
                    <GridViewColumn Header="Volume (lots)" DisplayMemberBinding="{Binding Path=Volume}" />
                    <GridViewColumn Header="Opening Price" DisplayMemberBinding="{Binding OpeningPrice}"/>
                    <GridViewColumn Header="Profit" DisplayMemberBinding="{Binding Profit}"/>
                </GridView>
            </ListView.View>
        </ListView>
        <TextBlock Text="Closed Orders" FontSize="16" FontWeight="Bold" Margin="0,20,0,0" Foreground="Red"/>
        <ListView Name="listClosedOrders" ItemsSource="{Binding CurrentSession.ClosedOrders}" Margin="0,10,0,0" >
            <ListView.View>
                <GridView ColumnHeaderContainerStyle="{DynamicResource ColumnHeaderContainerStyleBase}" ColumnHeaderTemplate="{DynamicResource ColumnHeaderTemplate}">
                    <GridViewColumn Header="Type">
                        <GridViewColumn.CellTemplate>
                            <DataTemplate>
                                <Border>
                                    <DockPanel>
                                        <Ellipse Width="25" Height="15" Name="icon" DockPanel.Dock="Left"  />
                                        <TextBlock Text="{Binding Type}" Name="content" VerticalAlignment="Center" Margin="5,0,0,0"/>
                                    </DockPanel>
                                </Border>
                                <DataTemplate.Triggers>
                                    <Trigger Property="Text" SourceName="content" Value="BuyOrder">
                                        <Setter TargetName="icon" Property="Fill" Value="Blue"/>
                                    </Trigger>
                                    <Trigger Property="Text" SourceName="content" Value="SellOrder">
                                        <Setter TargetName="icon" Property="Fill" Value="Red"/>
                                    </Trigger>
                                </DataTemplate.Triggers>
                            </DataTemplate>
                        </GridViewColumn.CellTemplate>
                    </GridViewColumn>
                    <GridViewColumn Header="Date" DisplayMemberBinding="{Binding Path=TimeStamp}"/>
                    <GridViewColumn Header="Currency Symbol" DisplayMemberBinding="{Binding Path=CurrencySymbol}"/>
                    <GridViewColumn Header="Volume (lots)" DisplayMemberBinding="{Binding Path=Volume}" />
                    <GridViewColumn Header="Opening Price" DisplayMemberBinding="{Binding OpeningPrice}"/>
                    <GridViewColumn Header="Closing Price" DisplayMemberBinding="{Binding ClosingPrice}"/>
                    <GridViewColumn Header="Profit" DisplayMemberBinding="{Binding Profit}"/>
                </GridView>
            </ListView.View>
        </ListView>

    </StackPanel>

</UserControl>
